<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>找到数组的某一项</title>
</head>
<body>
    

    <script>
    
    /* (function () {
        
        // 找到具体的某一项 用find  find -> 只能找出符合条件的第一项
        let ary = [10,12,15,16];
        var result = ary.find(item => item.toString().indexOf('5')>-1);
        console.log(result);
        
    })();


    (function () {

        let s = "what the world";
        console.log(s.indexOf('w'));

    })(); */


    (function () {

        // filter 方法 找到所有符合条件的项目
        let ary = ["word","demo","apple","pear","book"];
        let arr = ary.filter(element => element.indexOf('o')>-1);
        console.log(`arr - ${arr}`);

    })();

    </script>
</body>
</html>